Imports WindowsLive.Writer.Api
Imports System.Windows.Forms


Partial Class TagsEditor
    Inherits SmartContentEditor
    Implements IDisposable

    'Private _editorSite As WindowsLive.Writer.Api.ISmartContentEditorSite

    Public Sub New(ByVal editorSite As WindowsLive.Writer.Api.ISmartContentEditorSite)

        MyBase.New()

        InitializeComponent()

        'OnContentEdited()
        'Threading.Thread.Sleep(1000)

        ' FindTags()

        txtEditorTags.Text = InsertSmartTags.myTags.ToString


    End Sub



    Private Sub btnUpdate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnUpdate.Click

        Dim myCreate As CreateTags = New CreateTags

        InsertSmartTags.myTags = txtEditorTags.Text.ToString

        SelectedContent.Properties.SetString("TAGS", myCreate.CreateTags(InsertSmartTags.myTags.Trim))

        OnContentEdited()

    End Sub


    Private Sub FindTags()
        Dim myTags As String = Nothing
        Dim myStart As Integer = 0
        Dim myEnd As Integer = 0

        myStart = InStr(SelectedContent.Properties.GetString("TAGS", String.Empty).ToString, "StartInsertedTags:")
        myEnd = InStr(SelectedContent.Properties.GetString("TAGS", String.Empty).ToString, ":EndInsertedTags")

        If InStr(SelectedContent.Properties.GetString("TAGS", String.Empty).ToString, "StartInsertedTags") > 0 Then
            InsertSmartTags.myTags = SelectedContent.Properties.GetString("TAGS", String.Empty).ToString.Substring((myStart + 18), (myEnd - (myStart + 19))).ToString.Trim
        End If

        myTags = Nothing
        myStart = Nothing
        myEnd = Nothing

    End Sub

    'Protected Overrides Sub Finalize()
    '    MyBase.Finalize()
    'End Sub

    Private Sub btnGetTags_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnGetTags.Click

        FindTags()
        txtEditorTags.Text = InsertSmartTags.myTags.ToString

    End Sub
End Class





